package digui;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }
//  . 开幕式焰火
public class Lcp44 {

    public int numColor(TreeNode root) {
        HashSet<Integer> values = new HashSet<>();
        preOrderRecur(root,values);
        return values.size();
    }

    public static   void preOrderRecur(TreeNode root, HashSet<Integer> values){
        if (root==null){
            return;
        }
         values.add(root.val);
        preOrderRecur(root.left,values);
        preOrderRecur(root.right,values);
    }

    public static void main(String[] args) {

        TreeNode root= new TreeNode(5);
        TreeNode treeNode1 = new TreeNode(3);
        TreeNode treeNode2= new TreeNode(1);
        TreeNode treeNode3 = new TreeNode(2);
        TreeNode treeNode4= new TreeNode(6);
        root.left=treeNode1;
        root.right=treeNode3;
        treeNode1.left=treeNode2;
        treeNode3.right=treeNode4;

        Lcp44 lcp44 = new Lcp44();
        System.out.println(lcp44.numColor(root));
    }



}
